﻿using AgileDevTool.UserControls;
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace AgileDevTool.Helpers
{
    public class UIHelper
    {
        public static void Toast(StackPanel sp_Toast, string msg, int? sleep = 1500)
        {
            var background = new SolidColorBrush(Color.FromArgb(255, 34, 177, 76));
            var foreground = new SolidColorBrush(Colors.White);
            var br = new ToastUserControl(msg, background, foreground);
            br.HorizontalAlignment = HorizontalAlignment.Center;
            br.VerticalAlignment = VerticalAlignment.Center;
            sp_Toast.Children.Insert(0, br);

            if (sleep.HasValue)
            {
                Task.Run(() =>
                {
                    Thread.Sleep(sleep.GetValueOrDefault());
                    sp_Toast.Dispatcher.Invoke(() =>
                    {
                        sp_Toast.Children.Remove(br);
                    });
                });
            }
        }
        
        public static TextBlock tbk_File;

        public static ICSharpCode.AvalonEdit.TextEditor rtb1;

        public static Image img1;

        public static TextBlock tbk_Url;

        public static WebBrowser wb1;

        public static TreeView tree1;
    }
}
